package com.steakliu.springasync.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;

/**
 * 功能说明：
 * <p>
 * Original @Author: steakliu-刘牌, 2022-06-26  11:17
 * <p>
 * Copyright (C)2020-2022  小四的技术之旅 All rights reserved.
 */
@Component
@Slf4j
@Async
public class AsyncService {

    public void task1() throws InterruptedException {
        Thread.sleep(2000);
        log.info("=====开始执行task1====={}",Thread.currentThread().getName());
    }

    public String task2(){
        log.info("=====开始执行task2====={}",Thread.currentThread().getName());
        return "task2";
    }

    public void task3(){
        log.info("=====开始执行task3====={}",Thread.currentThread().getName());
    }

    public void task4(){
        log.info("=====开始执行task4====={}",Thread.currentThread().getName());
    }
}
